define(['jtopo','Json2xml'],function (jtopo,Json2xml){

	var customTextNode = function (jsonObj){
		this.initialize = function (){
			jsonObj._id && customTextNode.prototype.initialize.apply(this, arguments);
		}
		this.initialize();
		this.deserialize(jsonObj);
	}
	customTextNode.prototype = new JTopo.TextNode();

	customTextNode.prototype.serialize = function (){
		var _self = this;
		var jsonObj = {
			dynText : {
				_id : _self.id,
				_text : _self.text,
				_x : _self.x,
				_y : _self.y,
				_width : _self.width,
				_height : _self.height,
				_color : _self.fontColor,
				_borderColor : '',
				_backgroundColor : '',
				_fontSize : _self.fontSize,
				_fontFamily : _self.fontFamily,
				_bold : 'bold',
				_italic : '',
				_underline : '',
				_align : ''
			}
		};
		var json2xml2 = new Json2xml();
		var resultXml_str = json2xml2.json2xml_str(jsonObj);
		return resultXml_str;
	}
	customTextNode.prototype.deserialize = function (jsonObj){
		this.x = Number(jsonObj._x);
		this.y = Number(jsonObj._y);
		this.width = jsonObj._width?Number(jsonObj._width):40;
		this.height = jsonObj._height?Number(jsonObj._height):40;
		this.id = jsonObj._id;
		this.text = jsonObj._text;
		this.name = jsonObj._text;
		this.fontColor = jsonObj._color;
		!jsonObj._fontSize && (jsonObj._fontSize = '12');
		//新增方便取值
		this.fontSize = jsonObj._fontSize;
		!jsonObj._fontFamily && (jsonObj._fontFamily = 'Consolas');
		//新增方便取值
		this.fontFamily = jsonObj._fontFamily;
		this.font = jsonObj._fontSize + "px " + jsonObj._fontFamily;
		jsonObj._bold && ( this.font = "bold " + this.font);

	}

	return customTextNode;
	
});
